package cn.tedu.home1ess.admin.navgation.controller;

import cn.tedu.common.response.JsonResult;
import cn.tedu.home1ess.admin.navgation.pojo.param.NavgationAddParam;
import cn.tedu.home1ess.admin.navgation.pojo.param.NavgationUpdateParam;
import cn.tedu.home1ess.admin.navgation.pojo.vo.NavgationVO;
import cn.tedu.home1ess.admin.navgation.service.INavgationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "导航管理")
@RequestMapping("/navgation")
@RestController
@Validated
public class NavgationController {
    @Autowired
    private INavgationService navgationServiceImpl;

    //查询所有的内容
    @GetMapping("navgationAll")
    @ApiOperation("获取全部导航")
    public JsonResult listForContent(){
        List<NavgationVO> navgationList=navgationServiceImpl.listForContent();
        return JsonResult.ok(navgationList);
    }
    //查询单个导航
    @GetMapping("{id}/navgationSelect")
    @ApiOperation("查询单个导航")
    public JsonResult selectById(@PathVariable Long id){
        System.out.println("id1111111 = " + id);
        NavgationVO navgation=navgationServiceImpl.selectById(id);
        System.out.println("navgation1111111 = " + navgation);
        return JsonResult.ok(navgation);
    }

    //增加导航
    @PostMapping("navgationAdd")
    @ApiOperation("增加导航")
    public JsonResult addNavgation(NavgationAddParam navgationAddParam){
        navgationServiceImpl.addNavgation(navgationAddParam);
        return JsonResult.ok();
    }

    //删除导航
    @PostMapping("{id}/navgationDelete")
    @ApiOperation("删除导航")
    public JsonResult deleteNavgation(@PathVariable Long id){
        navgationServiceImpl.DeleteNavgation(id);
        return JsonResult.ok();
    }
    //修改导航
    @PostMapping("navgationUpdate")
    @ApiOperation("修改导航")
    public JsonResult updateNavgation(NavgationUpdateParam  navgationUpdateParam){
        System.out.println("navgationUpdateParam = " + navgationUpdateParam);
        navgationServiceImpl.UpdateNavgation(navgationUpdateParam);
        return JsonResult.ok();
    }



}










